package com.xl.singletonPattern;

public class Client {
    public static void main(String[] args) {
        //测试单例模式
        System.out.println("===单例模式测试===");
        //第一次获取实例
        Singleton instance1 = Singleton.getInstance();
        instance1.showMessage();
        //第二次获取实例
        Singleton instance2 = Singleton.getInstance();
        instance2.showMessage();

        //验证是否为同一个实例
        System.out.println("instance1 == instance2: "+(instance1 == instance2));
        System.out.println("instance1 hashcode: "+instance1.hashCode());
        System.out.println("instance2 hashcode: "+instance2.hashCode());

    }
}
